import request from '@/utils/request'

// 发布问题
export function postQuestions(data) {
  return request({
    url: '/question/addQuestion',
    method: 'post',
    data
  })
}

// 首页问答列表
export function getQuestionList(data) {
  return request({
    url: '/question/getQuestionList',
    method: 'get',
    params: { pageIndex: data.pageIndex, pageSize: data.pageSize }
  })
}

// 根据id获取问答详情
export function getQuestionById(data) {
  return request({
    url: '/question/getQuestionById',
    method: 'get',
    params: { id: data.id, userId: data.userId }
  })
}

// 给个抱抱
export function giveAHug(data) {
  return request({
    url: '/question/giveHug',
    method: 'get',
    params: { questionId: data.questionId, userId: data.userId }
  })
}
// 收藏该问答
export function collect(data) {
  return request({
    url: '/question/collect',
    method: 'get',
    params: { questionId: data.questionId, userId: data.userId }
  })
}
// 取消收藏该问答
export function cancelCollect(data) {
  return request({
    url: '/question/cancelCollect',
    method: 'get',
    params: { questionId: data.questionId, userId: data.userId }
  })
}

export function addReadCount(data) {
  return request({
    url: '/question/addReadCount',
    method: 'get',
    params: { id: data.id }
  })
}

export function collectionQuestion(data) {
  return request({
    url: '/question/collectionQuestion',
    method: 'get',
    params: { userId: data.userId }
  })
}

export function myQuestion(data) {
  return request({
    url: '/question/myQuestion',
    method: 'get',
    params: { userId: data.userId }
  })
}
// --------------------------------------------------------------------------以下为回答api

// 提交回答
export function addQuestionAnswer(data) {
  return request({
    url: '/qa/addQuestionAnswer',
    method: 'post',
    data
  })
}

// 获取回答列表
export function findQuestionAnswerList(data) {
  return request({
    url: '/qa/findQuestionAnswerList',
    method: 'get',
    params: { questionId: data.questionId, userId: data.userId }
  })
}

// 有用
export function useful(data) {
  return request({
    url: '/qa/useful',
    method: 'get',
    params: { qaId: data.qaId, userId: data.userId }
  })
}

// 取消有用
export function cancelUseful(data) {
  return request({
    url: '/qa/cancelUseful',
    method: 'get',
    params: { qaId: data.qaId, userId: data.userId }
  })
}

// 关注
export function focus(data) {
  return request({
    url: '/qa/focus',
    method: 'get',
    params: { answerUserId: data.answerUserId, loginUserId: data.loginUserId }
  })
}
// 取消关注
export function unfocus(data) {
  return request({
    url: '/qa/unfocus',
    method: 'get',
    params: { answerUserId: data.answerUserId, loginUserId: data.loginUserId }
  })
}

// 评论
export function sendComment(data) {
  return request({
    url: '/qa/sendComment',
    method: 'post',
    data
  })
}

export function qaCommentVo(data) {
  return request({
    url: '/qaComment/qaCommentVo',
    method: 'get',
    params: { qaId: data.qaId }
  })
}

export function findQaByUserId(data) {
  return request({
    url: '/qa/findQaByUserId',
    method: 'get',
    params: { userId: data.userId }
  })
}

export function userQaCount(data) {
  return request({
    url: '/qa/userQaCount',
    method: 'get',
    params: { userId: data.userId }
  })
}

export function tipOff(data) {
  return request({
    url: '/qa/tipOff',
    method: 'get',
    params: { qaId: data.qaId, userId: data.userId }
  })
}

export function questionAnswerList(data) {
  return request({
    url: '/qa/questionAnswerList',
    method: 'get',
    params: { username: data.username, username1: data.username1, title: data.title,
      startTime: data.startTime, endTime: data.endTime, pageIndex: data.pageIndex }
  })
}

export function delQuestionAnswer(data) {
  return request({
    url: '/qa/delQuestionAnswer',
    method: 'get',
    params: { qaId: data.qaId }
  })
}
